<?PHP
unset($_SESSION['updateArray']);
?>
<TABLE width="100%" border="0" cellpadding="4" cellspacing="0" style="mainTableBGColor">
	<TR><TD valign="top" align="center">
	


<script language="JavaScript">
<!--
function formCheck(){
	var msg = "";
	if(document.form.title.value == ""){//Program Title field
		msg = "Please enter a Program Title!\n\n";
		document.form.title.focus();
	}
	
	if(document.form.hour.value == "not_selected" || document.form.minute.value == "not_selected" || document.form.seconds.value == "not_selected"){
	msg = msg + "Please choose a proper Air Time!\n\n";	
	}
	

	
	if(document.form.mon.checked == false && document.form.tue.checked == false && document.form.wed.checked == false && document.form.thu.checked == false && document.form.fri.checked == false && document.form.sat.checked == false && document.form.sun.checked == false){
	msg = msg + "Please select the days this program airs!\n\n";	
	}
	
	
	if(msg == ""){//no empty fields, ok to submit
  	var display = "Please confirm this is the correct information before submitting:\n\n\n PROGRAM TITLE:  " + document.form.title.value + "\n\n AIR TIME:  " + document.form.hour.value + ":" + document.form.minute.value+ ":" + document.form.seconds.value + "  " + document.form.ampm.value + "\n\n";
	
	//Confirm Start Date
	if(document.form.startMonth.value == "not_selected" || document.form.startDay.value == "not_selected" || document.form.startYear.value == "not_selected"){
	display = display + "START DATE:  No Start Date Specified\n\n"; 
	}else{
	display = display + "START TIME:  " + document.form.startMonth.value + "/" + document.form.startDay.value +"/" + document.form.startYear.value + "\n\n"; 
	}
	
	//Confirm End Date
	if(document.form.endMonth.value == "not_selected" || document.form.endDay.value == "not_selected" || document.form.endYear.value == "not_selected"){
	display = display + "END DATE:  No End Date Specified" + "\n\n DAYS:  "; 
	}else{
	display = display + "END TIME:  " + document.form.endMonth.value + "/" + document.form.endDay.value +"/" + document.form.endYear.value + "\n\n DAYS:  "; 
	}
	
	
	//Confirm Days
	if(document.form.mon.checked == true){
	display = display + "mon   ";
	}
	if(document.form.tue.checked == true){
	display = display + "tue   ";
	}
	if(document.form.wed.checked == true){
	display = display + "wed   ";
	}
	if(document.form.thu.checked == true){
	display = display + "thu   ";
	}
	if(document.form.fri.checked == true){
	display = display + "fri   ";
	}
	if(document.form.sat.checked == true){
	display = display + "sat   ";
	}
	if(document.form.sun.checked == true){
	display = display + "sun   ";
	}

	display = display + "\n\nSOURCE:  " + document.form.source.value +  "\n\n" + "TYPE:  " + document.form.type.value;
	
		 if(confirm(display)){
		   document.form.submit();
		 }else{
		   return false;	
		 }
	}else{
	alert(msg);
	}
	
}
//-->
</script> 

	
<FORM name="form" action="formaction.php" method="post" enctype="multipart/form-data" onKeyPress="swallowEnter()">	
		<TABLE border="1" width="625" cellpadding="4" cellspacing="0">
			<TR class="even">
				<TD class="formDescriptiveText">Program Title:</TD>
				<TD class="formElementTextLeft"><input name="title" type="text" size="30" onkeypress="return swallowEnter(event,this.form)"></TD>
			</TR>
			
			<TR class="odd">
				<TD class="formDescriptiveText">Air Time:</TD>
				<TD class="formElementTextLeft">
				<?php
				//#####################################
				// Form Item - Hour
				//#####################################
				echo "\n<select name=\"hour\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n";
					echo("<option value=\"not_selected\" selected>hour</option>\n"); 
				for ($i = 1; $i < 13; $i++) {
					//$value = str_pad($i, 2, "0", STR_PAD_LEFT);  
					echo("<option value=\"$i\">$i</option>\n"); 
				}
				echo "</select>&nbsp; : &nbsp;\n\n";
				
				
				//#####################################
				// Form Item - Minute
				//#####################################
				echo "\n<select name=\"minute\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n";
					echo("<option value=\"not_selected\" selected>minute</option>\n"); 
				for ($i = 0; $i < 60; $i++) {
					$value = str_pad($i, 2, "0", STR_PAD_LEFT);  
					echo("<option value=\"$value\">$value</option>\n"); 
				}
				echo "</select>&nbsp; : &nbsp;\n\n";
				
				//#####################################
				// Form Item - Seconds
				//#####################################
				echo "\n<select name=\"seconds\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n";
					echo("<option value=\"not_selected\" selected>seconds</option>\n"); 
				for ($i = 0; $i < 60; $i++) {
					$value = str_pad($i, 2, "0", STR_PAD_LEFT);  
					echo("<option value=\"$value\">$value</option>\n"); 
				}
				echo "</select>&nbsp; &nbsp;\n\n";	
				
				//#####################################
				// Form Item - AM / PM
				//#####################################
				echo "\n<select name=\"ampm\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n";
				echo "<option value=\"AM\" selected>AM</option>";
				echo "<option value=\"PM\">PM</option>";
				echo "</select>&nbsp; &nbsp;\n\n";	
				?>
				</TD>
			</TR>
			

			<TR class="even">
				<TD class="formDescriptiveText">Start Date:</TD>
				<TD class="formElementTextLeft">
				<?PHP
				        //#####################################
						// Form Item - Start Date
						//#####################################
						//Month Drop Down List
						echo("<select name=\"startMonth\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n");
						 echo("<option value=\"not_selected\" selected>month</option>\n");
						for ($i = 1; $i < 13; $i++) {
						$value = str_pad($i, 2, "0", STR_PAD_LEFT);
						 echo("<option value=\"$value\">". date("F",mktime (0,0,0,$i,1,2005) )."</option>\n");
						}
						echo("</SELECT>\n\n");
						
						//Day Drop Down List
						echo("<select name=\"startDay\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n");
							echo("<option value=\"not_selected\" selected>day</option>\n");
						for ($i = 1; $i < 32; $i++) {
							$value = str_pad($i, 2, "0", STR_PAD_LEFT);
							echo("<option value=\"$value\">$value</option>\n");
						}
						echo("</SELECT>\n\n");
						
						
						//Year Drop Down List
						echo("<select name=\"startYear\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\"> \n");
							echo("<option value=\"not_selected\" selected>year</option>\n");
							for ($i = 0; $i < 3; $i++) {
								echo("<option value=\"" . (date("Y") + $i ). "\">" . (date("Y") + $i ) . "</option>\n");
							}
						echo("</SELECT> \n");
				
				
				
				?>&nbsp; (optional)
				</TD>
			</TR>
			
			<TR class="odd">
				<TD class="formDescriptiveText">End Date:</TD>
				<TD class="formElementTextLeft">
				<?PHP
				        //#####################################
						// Form Item - END Date
						//#####################################
						//Month Drop Down List
						echo("<select name=\"endMonth\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n");
						 echo("<option value=\"not_selected\" selected>month</option>\n");
						for ($i = 1; $i < 13; $i++) {
						$value = str_pad($i, 2, "0", STR_PAD_LEFT);
						 echo("<option value=\"$value\">". date("F",mktime (0,0,0,$i,1,2005) )."</option>\n");
						}
						echo("</SELECT>\n\n");
						
						//Day Drop Down List
						echo("<select name=\"endDay\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\">\n");
							echo("<option value=\"not_selected\" selected>day</option>\n");
						for ($i = 1; $i < 32; $i++) {
							$value = str_pad($i, 2, "0", STR_PAD_LEFT);
							echo("<option value=\"$value\">$value</option>\n");
						}
						echo("</SELECT>\n\n");
						
						
						//Year Drop Down List
						echo("<select name=\"endYear\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\"> \n");
							echo("<option value=\"not_selected\" selected>year</option>\n");
							for ($i = 0; $i < 3; $i++) {
								echo("<option value=\"" . (date("Y") + $i ). "\">" . (date("Y") + $i ) . "</option>\n");
							}
						echo("</SELECT> \n");
				
				
				
				?>&nbsp; (optional)
				
				
				
				</TD>
			</TR>
			
			<TR class="even">
				<TD class="formDescriptiveText">Days of Week:</TD>
				<TD class="formElementTextLeft">
				<?PHP
				//#####################################
				// Form Item - DAYS
				//#####################################
				echo "mon:<INPUT name=\"mon\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "tue:<INPUT name=\"tue\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "wed:<INPUT name=\"wed\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "thu:<INPUT name=\"thu\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "fri:<INPUT name=\"fri\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "sat:<INPUT name=\"sat\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				echo "sun:<INPUT name=\"sun\" type=\"checkbox\" value=\"true\" onkeypress=\"return swallowEnter(event,this.form)\">  &nbsp;&nbsp;";
				?>				
				</TD>
			</TR>
				
			<TR class="odd">
				<TD class="formDescriptiveText">Source:</TD>
				<TD class="formElementTextLeft">
				<?PHP
				//#####################################
				// Form Item - SOURCE
				//#####################################
				//Source Drop Down List
				echo("<select name=\"source\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\" onChange=\"showSourceOther()\">\n");
				for ($i = 0; $i < (count($ProgramSources)/2); $i++) {
					echo("<option value=\"" . $ProgramSources[($i + $i)] . "\">" . $ProgramSources[($i + $i + 1)] . "</option>\n");
				}
				echo("</SELECT>\n\n");
				?>&nbsp; <input id="source_other" name="source_other" type="text" value="Enter Optional Description:" size="25" style="visibility:hidden;" onFocus="clearSourceOther()">					
				</TD>
			</TR>				



			<TR class="even">
				<TD class="formDescriptiveText">Type:</TD>
				<TD class="formElementTextLeft">
				<!-- JAVASCRIPT FOR SHOWING "OTHER" TEXT FIELD-->
				<script language="JavaScript">
				<!--
				function showSourceOther(){
					if(document.form.source.value == 'Other'){
						document.getElementById("source_other").style.visibility = 'visible';
					}else{
						document.getElementById("source_other").style.visibility = 'hidden';
					}
				}
				
				
				
				
				
				function showOther(){
					if(document.form.type.value == 'Other'){
						document.getElementById("type_other").style.visibility = 'visible';
					}else{
						document.getElementById("type_other").style.visibility = 'hidden';
					}
				}
				
				
				function clearOther(){
					document.form.type_other.value = "";
				}
				
				function clearSourceOther(){
					document.form.source_other.value = "";
				}				
				
	
				//-->
				</script> 
				
				<?PHP
				//#####################################
				// Form Item - Type
				//#####################################
				echo("<select name=\"type\" size=\"1\" onkeypress=\"return swallowEnter(event,this.form)\" onChange=\"showOther()\">\n");
				for ($i = 0; $i < (count($ProgramTypes)/2); $i++) {
					echo("<option value=\"" . $ProgramTypes[($i + $i)] . "\">" . $ProgramTypes[($i + $i + 1)] . "</option>\n");
				}
				echo("</SELECT>\n\n");
				?>&nbsp; <input id="type_other" name="type_other" type="text" value="Enter Optional Description:" size="25" style="visibility:hidden;" onFocus="clearOther()">					
				</TD>
			</TR>

				
		</TABLE>
<INPUT name="action" type="hidden" value="enterPrograms"><INPUT name="Submit" type="button" class="inputButton" value="Submit" onClick ="formCheck()" style="margin-bottom:5px; margin-top:5px;"> &nbsp; &nbsp; &nbsp; <INPUT name="Reset" type="reset" class="inputButton" value="Reset" style="margin-bottom:5px; margin-top:5px;">
</FORM>		
	</TD></TR>
</TABLE>

